package com.zz.parkingsystem.controller.user;

import com.zz.parkingsystem.entity.UserFeedback;
import com.zz.parkingsystem.service.UserFeedbackService;
import com.zz.parkingsystem.util.OssUtil;
import com.zz.parkingsystem.util.Result;
import com.zz.parkingsystem.util.ResultGenerator;
import com.zz.parkingsystem.vo.ShowVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@ResponseBody
@Controller
@RequestMapping("/userFeedback")
@Api(value = "",tags = "用户反馈接口")
public class FeedbackController {
    @Autowired
    private UserFeedbackService userFeedbackService;
    @Autowired
    private OssUtil ossUtil;//引入工具类
    //用户反馈
    @PostMapping("/add")
    public Result feedback(@RequestBody UserFeedback userFeedback){
        userFeedbackService.insertSelectiveUser(userFeedback);
        return ResultGenerator.genSuccessResult("用户反馈成功");
    }

    @ApiOperation(value = "上传图片")
    @PostMapping("/uploadoss")
    public Result fileUpload(@RequestParam("file") MultipartFile file) {
        try {
            String url = ossUtil.uploadFile(file); //调用OSS工具类
            System.out.println(url);
            return ResultGenerator.genSuccessResult(url);
        } catch (Exception e) {
            return  ResultGenerator.genFailResult("上传失败");
        }
    }
}
